﻿// Copyright (c) Pomelo Foundation. All rights reserved.
// Licensed under the MIT. See LICENSE in the project root for license information.

using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Query.Expressions;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;
using Pomelo.EntityFrameworkCore.MyCat.Infrastructure.Internal;

// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore.Query.Sql.Internal
{
    public class MyCatQuerySqlGenerationHelperFactory : QuerySqlGeneratorFactoryBase
    {
        private readonly IMyCatOptions _myCatOptions;
        public MyCatQuerySqlGenerationHelperFactory(
            [NotNull] QuerySqlGeneratorDependencies dependencies,
             [NotNull] IMyCatOptions myCatOptions
            )
            : base(dependencies)
        {
            _myCatOptions = myCatOptions;
        }

        public override IQuerySqlGenerator CreateDefault(SelectExpression selectExpression)
            => new MyCatQuerySqlGenerator(
                Dependencies,
                Check.NotNull(selectExpression, nameof(selectExpression)),
                _myCatOptions.RowNumberPagingEnabled);

    }
}
